package lee.vioson.ebook.viewmodels

import kotlinx.coroutines.flow.StateFlow
import lee.vioson.composecommon.base.mvi.Reducer
import lee.vioson.composecommon.base.mvi.UiEvent
import lee.vioson.composecommon.base.mvi.UiState
import lee.vioson.ebook.data.AppContainer
import lee.vioson.ebook.data.pagedata.pageDataSource
import lee.vioson.remotedata.bean.requestbody.UniqueRequestBody

/**
 *Author:viosonlee
 *Date:2023/6/12
 *DESCRIPTION:
 */
class FeedbackHistoryViewModel(
    private val appContainer: AppContainer
) : AppViewModel<FeedbackHistoryViewModel.State, FeedbackHistoryViewModel.Event>(appContainer.appEvent) {

    private val reducer = SubReducer(State())

    override val state: StateFlow<State>
        get() = reducer.state

    override fun sendEvent(event: Event) {
        reducer.sendEvent(event)
    }

    val feedbackList = pageDataSource {
        appContainer.feedbackRepository.fetchFeedbackList(
            UniqueRequestBody(
                it,
                pageSize,
                appContainer.uniqueId
            )
        )
    }


    private class SubReducer(initialState: State) :
        Reducer<State, Event>(initialState) {
        override fun reduce(oldState: State, event: Event) {

        }
    }


    sealed class Event : UiEvent {

    }

    class State : UiState
}

